package sword;

/**
 * @Author: 海琳琦
 * @Date: 2022/5/28 16:32
 */
public class Title53II {

    public int missingNumber(int[] nums) {
        //数字范围[0, n]
        int n = nums.length;
        int left = 0, right = n - 1;
        while (left <= right) {
            //计算中间坐标的索引
            int middle = (left + right) / 2;
            if (middle == nums[middle]) {
                left = middle + 1;
            } else{
                right = middle - 1;
            }
        }
        return left;
    }

    public static void main(String[] args) {

    }
}
